#include<iostream>
using namespace std;
int main() {
	int n,m,i,j;
	cin>>n>>m;
	char a[n+2][m+2],b[n+2][m+2];
	for(i=1;i<=n;i++)for(j=1;j<=m;j++)cin>>a[i][j];
	for(i=1;i<=n;i++)for(j=1;j<=m;j++)b[i][j]='0'; 
    for(i=1;i<=n;i++) {
    	for(j=1;j<=m;j++) { 
     		if(a[i][j]=='*')b[i][j]='*';
    		if(a[i][j]=='?') {
    			if(a[i][j+1]=='*')b[i][j]++;
				if(a[i][j-1]=='*')b[i][j]++;
				if(a[i-1][j]=='*')b[i][j]++;
				if(a[i+1][j]=='*')b[i][j]++;
				if(a[i+1][j+1]=='*')b[i][j]++;
				if(a[i+1][j-1]=='*')b[i][j]++;
				if(a[i-1][j+1]=='*')b[i][j]++;
				if(a[i-1][j-1]=='*')b[i][j]++;
			}
		}
	}
	for(i=1;i<=n;i++) {
		for(j=1;j<=m;j++)cout<<b[i][j];
		cout<<endl;
	}
	return 0;
}